import numpy as np

class cal_angle(object):
    def __init__(self):
        return

    @staticmethod
    def cal_angle(arr1, arr2):
        arr1_rad = np.radians(arr1)
        arr2_rad = np.radians(arr2)
        
        # 将经纬度转换为三维坐标
        x1 = np.cos(arr1_rad[:,1]) * np.cos(arr1_rad[:,0])
        y1 = np.cos(arr1_rad[:,1]) * np.sin(arr1_rad[:,0])
        z1 = np.sin(arr1_rad[:,1])

        x2 = np.cos(arr2_rad[:,1]) * np.cos(arr2_rad[:,0])
        y2 = np.cos(arr2_rad[:,1]) * np.sin(arr2_rad[:,0])
        z2 = np.sin(arr2_rad[:,1])

        vec1 = np.array([x1, y1, z1])
        vec2 = np.array([x2, y2, z2])

        angle_deg = np.degrees(np.acos(np.dot(vec1,vec2) / (np.linalg.norm(vec1) * np.linalg.norm(vec2))))
        return angle_deg
        